import time
import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)

StepPins = [17,18,23,22]


for pin in StepPins:
	print 'Setup pins'
	GPIO.setup(pin,GPIO.OUT)
	GPIO.output(pin, False)

StepCounter = 0
WaitTime = 0.001
StepCount2 = 8

Seq2 = []
Seq2 = range(0, StepCount2)
Seq2[0]= [1,0,0,0]
Seq2[1]= [1,1,0,0]
Seq2[2]= [0,1,0,0]
Seq2[3]= [0,1,1,0]
Seq2[4]= [0,0,1,0]
Seq2[5]= [0,0,1,1]
Seq2[6]= [0,0,0,1]
Seq2[7]= [1,0,0,1]

Seq = Seq2
StepCount = StepCount2

run = False


def motorManager():
    while 1:
        pass

def rotateMotor(a):
    run = True
    StepCounter = 0
    while run == True:
	for pin in range(0, 4):
		xpin = StepPins[pin]
		if Seq[StepCounter][pin]!=0:
			GPIO.output(xpin, True)
		else:
			GPIO.output(xpin, False)
	StepCounter += 1
	if (StepCounter==StepCount):
		StepCounter = 0
	time.sleep(WaitTime)

def stopRotating():
    run = False


